import { number } from 'echarts'
import request from './request'

// 登录
export const loginApi = (data: { username: string, password: string }): Promise<Ajax.AjaxRes> => request.post('/login', data)
// 获取菜单
export const menuList = (): Promise<Ajax.AjaxRes> => request.get('menus')
// 获取用户
export const userList = (params: { query: string, pagenum: number, pagesize: number }): Promise<Ajax.AjaxRes> => request.get('users', { params })
// 添加用户
export const addUser = (data: {
  username: string;
  password: string;
  email: string;
  mobile: string;
}): Promise<Ajax.AjaxRes> => request.post('users', data)
// 加载用户
export const loadUser = (id: number): Promise<Ajax.AjaxRes> => request.get('users/' + id)
// 删除用户
export const delUser = (id: number): Promise<Ajax.AjaxRes> => request.delete('users/' + id)
// 切换状态
export const changeState = (id: number, state: boolean): Promise<Ajax.AjaxRes> => request.put(`users/${id}/state/${state}`)
// 获取所有角色
export const roleList = (): Promise<Ajax.AjaxRes> => request.get('roles')
// 数据统计
export const reportList = (): Promise<Ajax.AjaxRes> => request.get('reports/type/1')
// 订单
export const order = (params: any): Promise<Ajax.AjaxRes> => request.get('orders', { params })
// 测试物流单号
export const orderNo = (): Promise<Ajax.AjaxRes> => request.get('/kuaidi/1106975712662')
// 商品列表
export const goodList = (params: { query: string; pagenum: number; pagesize: number; }): Promise<Ajax.AjaxRes> => request.get('goods', { params })
// 编辑商品
export const updateGood = (id: number, params: any): Promise<Ajax.AjaxRes> => request.put('goods/' + id, { params })
// 删除商品
export const delGoods = (id: number): Promise<Ajax.AjaxRes> => request.delete(`goods/${id}`)
// 添加商品
export const addGoods = (data: any): Promise<Ajax.AjaxRes> => request.post('goods', data)
// 参数数据  动态（many）、静态(only)
export const attr = (id: number, type: string): Promise<Ajax.AjaxRes> => request.get(`categories/${id}/attributes`, { params: { sel: type } })
// 分类-属性
export const categoriesList = (): Promise<Ajax.AjaxRes> => request.get('categories')
// 添加分类-属性
export const addCategory = (id: number, data: any): Promise<Ajax.AjaxRes> => request.post(`categories/${id}/attributes`, data)
// 加载分类-属性
export const loadCategory = (cid: number, id: number): Promise<Ajax.AjaxRes> => request.get(`categories/${cid}/attributes/${id}`)
// 修改分类-属性
export const editCategory = (cid: number, id: number, data: any): Promise<Ajax.AjaxRes> => request.put(`categories/${cid}/attributes/${id}`, data)
// 删除分类-属性
export const delCategory = (cid: number, id: number): Promise<Ajax.AjaxRes> => request.delete(`categories/${cid}/attributes/${id}`)
// 添加 删除tag项
export const tagCategory = (cid: number, id: number, data: any): Promise<Ajax.AjaxRes> => request.put(`categories/${cid}/attributes/${id}`, data)

// 商品分类
export const categoryList = (params: {
  type: number,
  pagenum?: number,
  pagesize?: number
}): Promise<Ajax.AjaxRes> => request.get('categories', { params })
// 添加商品分类
export const categoryAdd = (data: any): Promise<Ajax.AjaxRes> => request.post('categories', data)
// 根据id获取商品分类
export const categoryLoad = (id: number): Promise<Ajax.AjaxRes> => request.get(`categories/${id}`)
// 编辑商品分类
export const categoryEdit = (id: number, data: any): Promise<Ajax.AjaxRes> => request.put(`categories/${id}`, data)
// 删除商品分类
export const categoryDel = (id: number): Promise<Ajax.AjaxRes> => request.delete(`categories/${id}`)







